package com.epam.tcs.actions;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.epam.tcs.actions.pages.Page;
import com.epam.tcs.actions.pages.PageFactory;

public class TeacherAction implements Action {

	@Override
	public void doExec(HttpServletRequest req, HttpServletResponse res) {

		String target = req.getRequestURI().substring(
				req.getContextPath().length());

		String[] tarr = target.split("/");
		Page page = null;
		
		try {
			if (tarr.length >= 3) {
				page = PageFactory.getPage(tarr[2]);
			} else {
				page = PageFactory.getPage("group");
			}
			page.doExec(req, res);
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.getMessage();
		}
			
		} 		

}

